/**
 * 
 */
package com.vanstone.imgapp.img.dal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;

import com.vanstone.imgapp.img.dal.object.CmsCategoryDO;

/**
 * @author shipeng
 *
 */
@Repository("cmsCommonDao")
public class CmsCommonDao {

  @Autowired
  private MongoTemplate mongoTemplate;

  public MongoTemplate getMongoTemplate() {
    return mongoTemplate;
  }

  public void inc_category_imgcount(long id, int inccount) {
    Query query = Query.query(Criteria.where("_id").is(id));
    Update update = new Update();
    update.inc("albumcount", inccount);
    this.mongoTemplate.updateFirst(query, update, CmsCategoryDO.class);
  }
}
